package com.kuqi.fragments;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.GridView;
import android.widget.ImageView;

import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;
import com.kuqi.R;
import com.kuqi.adapter.OtherPageGridAdapter;
import com.kuqi.entitiy.AreaItem;

import java.util.ArrayList;


public class OthersPageFragment extends Fragment {

	private ArrayList<AreaItem> areaList = new ArrayList<>();

	// 素材组, 用于渲染使用的素材
	private int[] area_images = new int[]{
			R.drawable.ic_other_music,
			R.drawable.ic_other_game,
			R.drawable.ic_other_read,
			R.drawable.ic_other_tv,
			R.drawable.ic_other_check,
			R.drawable.ic_other_op,
			R.drawable.ic_other_help,
			R.drawable.ic_other_happy};

	// 分类名称
	private String[] area_texts = new String[]{"音乐","游戏","读书","电视","升级","设置","帮助","捐赠"};


	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		// 构建area item 单条是数据格式显示对象
		for (int i = 0; i < area_images.length; i++) {
			AreaItem item = new AreaItem();
			item.setImg(area_images[i]);
			item.setText(area_texts[i]);
			areaList.add(item);
		}
	}


	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		// 引入 subarea显示布局,将area_item数据填充进去
		View rootView = inflater.inflate(R.layout.fragment_others, container, false);
		GridView areaGridView = rootView.findViewById(R.id.AreaGridView);
		areaGridView.setAdapter(new OtherPageGridAdapter(getActivity(), areaList));

		// 给下面添加一个可爱的gif
		ImageView other_more = rootView.findViewById(R.id.other_more);
		Glide.with(this).asGif().load(R.mipmap.no_more_thanks).into(other_more);

		return rootView;
	}



}
